import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { MultiImg } from './multiImg.entity';

@Injectable()
export class MultiImgService {
  constructor(
    @InjectRepository(MultiImg)
    private catsRepository: Repository<MultiImg>,
  ) {}

  /**
   * 查询视频id：根据任务id
   * @param trace_id 
   * @returns 
   */
  findVideoId_By_Trace_Id(trace_id: string): Promise<MultiImg>{
    return this.catsRepository.findOne({where:{trace_id:trace_id}})
  }

  /**
   * 查询某个图片的多图
   * @param video_id
   * @returns
   */
  find_By_Video(video_id: number): Promise<MultiImg[]> {
    return this.catsRepository.find({where:{video_id:video_id}});
  }

  findAll(): Promise<MultiImg[]> {
    return this.catsRepository.find();
  }

  findOne(id: any): Promise<MultiImg> {
    return this.catsRepository.findOne(id);
  }

  async remove(id: number): Promise<void> {
    await this.catsRepository.delete(id);
  }

  async create(cats: MultiImg): Promise<void> {
    await this.catsRepository.save(cats);
  }
}
